package com.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue directBootQueue(){
        return new Queue("directBootQueue");
    }

    @Bean
    public DirectExchange bootDirect(){
        return new DirectExchange("bootDirect");
    }

    /**
     * 只要当前方法的形参的类型以及参数名与某个携带了@Bean的方法的返回值类型以及方法名完全一致
     * Spring就会将这个方法的返回值对象注入到当前方法形参中
     */
    @Bean
    public Binding directBind(Queue directBootQueue,DirectExchange bootDirect){
        return BindingBuilder.bind(directBootQueue).to(bootDirect).with("bootKey");
    }


    @Bean
    public FanoutExchange fanoutBootExchange(){
        return new FanoutExchange("fanoutBootExchange");
    }

    @Bean
    public TopicExchange topicBootExchange(){
        return new TopicExchange("topicBootExchange");
    }

}
